<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/2/3
 * Time: 15:37
 */

namespace App\Http\Controllers\MiniProgramAdmin;


use App\Http\Logics\MiniProgramAdmin\CityLogic;
use App\Http\Traits\CityTrait;
use App\Http\Controllers\BaseController;
class CityController extends BaseController
{
    use CityTrait;
    /**
     * @SWG\Get(
     *     path="/city/detail",
     *     tags={"City"},
     *     description="获取城市详情",
     *     operationId="getCityDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="citycode",
     *         in="query",
     *         description="城市编码",
     *         type="integer",
     *         format="int32",
     *         required=false
     *     ),
     *     @SWG\Parameter(
     *         name="city_id",
     *         in="query",
     *         description="城市ID",
     *         type="integer",
     *         format="int32",
     *         required=false
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getCityDetail(){
        $citycode = $this->citycode;
        $city_id = $this->city_id;
        $data = [
            'citycode' => $citycode,
            'city_id' => $city_id
        ];
        $response = CityLogic::cityDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);

    }

    /**
     * @SWG\Post(
     *     path="/city/update",
     *     tags={"City"},
     *     description="更新城市信息",
     *     operationId="updateCity",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         type="string",
     *         required=true
     *     ),
     *     @SWG\Parameter(
     *         name="citycode",
     *         in="query",
     *         description="城市ID",
     *         type="integer",
     *         format="int32",
     *         required=true
     *     ),
     *     @SWG\Parameter(
     *         name="slogan",
     *         in="query",
     *         description="城市标语",
     *         type="string",
     *         required=true
     *     ),
     *     @SWG\Parameter(
     *         name="summary",
     *         in="query",
     *         description="城市简介",
     *         type="string",
     *         required=true
     *     ),
     *     @SWG\Parameter(
     *         name="banner",
     *         in="query",
     *         description="城市banner图",
     *         type="string",
     *         required=true
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function updateCity()
    {
        $citycode = $this->citycode;
        $slogan = $this->slogan;
        $summary = $this->summary;
        $banner = $this->banner;
        $data = [
            'citycode' => $citycode,
            'slogan' => $slogan,
            'summary' => $summary,
            'banner' => $banner
        ];
        $response = CityLogic::updateCity($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/city/changeStatus",
     *     tags={"City"},
     *     description="改变城市状态",
     *     operationId="changeStatus",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         type="string",
     *         required=true
     *     ),
     *     @SWG\Parameter(
     *         name="citycode",
     *         in="query",
     *         description="城市ID",
     *         type="integer",
     *         format="int32",
     *         required=true
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function changeStatus()
    {
        $citycode = $this->citycode;
        $data = [
            'citycode' => $citycode
        ];
        $response = CityLogic::changeStatus($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}